import global from './global'
// 封装http请求结合promise
/**
 * 参数option:包含url,data,method,timeout,header
 * 
 * 
 */
const http = (option) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: global.baseUrl + option.url,
			data: option.data || {},
			method: option.method || 'get',
			timeout: option.timeout || 6000,
			header: option.header || {
				"Content-Type": 'application/json'
			},
			success(res) {
				resolve(res)
			},
			fail(err) {
				reject(err)
			}
		})
	})
}

export default http